<template>
	<view class="settle-box-container">
		<!-- 全选 -->
		<label class="radio" @click="changeFullState">
			<radio color="#c00000" :checked="isFullChecked"><text>全选</text></radio>
		</label>
		<!-- 合计 -->
		<view class="count-box">
			合计: <text class="count">￥{{ checkedPrice}}</text>
		</view>
		<!-- 结算 -->
		<view class="settle" @click="settleLement">结算({{ checkedCount}})</view>
	</view>
</template>

<script>
	import {mapGetters,mapMutations,mapState} from 'vuex'
	export default {
		name:"my-settle",
		data() {
			return {
				
			};
		},
		computed:{
			...mapGetters('m_cart',['checkedCount','total','checkedPrice']),
			...mapGetters('m_user',['addstr']),
			...mapState('m_user',['token']),
			// 通过当前商品的个数total是否与选中的商品数量相同来判断是否为全选
			isFullChecked(){
			return	this.total === this.checkedCount
			}
		},
		methods:{
			...mapMutations('m_cart',['updateFullChecked']),
			changeFullState(){
				this.updateFullChecked(!this.isFullChecked)
			},
			settleLement(){
				if(!this.checkedCount) return uni.$showMge('请先勾选商品!')
				if(!this.addstr) return uni.$showMge('请先填写地址!')
				if(!this.token) return uni.$showMge('请先登录!')
			}
		}
	}
</script>

<style lang="scss">
.settle-box-container{
	position: fixed;
	bottom: 0;
	left: 0;
	width: 100%;
	height: 50px;
	background-color: white;
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding-left: 5px;
	font-size: 14px;
}
.count{
	color: #c00000;
}
.settle{
	height: 50px;
	line-height: 50px;
	min-width: 100px;
	background-color: #c00000;
	color: white;
	text-align: center;
	padding: 0 10px;
}
</style>
